package com.tiantian.springtest01.conf;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @ClassName SyncThreadConfig
 * @Description 线程池配置类
 * @Author tant
 * @Date 2021/5/19 14:36
 */
@Configuration
public class ThreadConfig00 {

    @Bean("TaskExecutor00")
    public TaskExecutor taskExecutor00() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(15);
        executor.setMaxPoolSize(15);
        executor.setKeepAliveSeconds(60);
        executor.setQueueCapacity(Integer.MAX_VALUE);
        executor.setThreadNamePrefix("TaskExecutor00_");
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
        return executor;
    }

}
